<!DOCTYPE html>
@extends('layouts.master3')
@section('css')
<link rel="stylesheet" href="/css/task.css">
<link rel="stylesheet" href="/css/edit/editormd.css"> 
<link rel="stylesheet" href="/css/count_down.css"> 
<link rel="stylesheet" href="/css/login.css"> 
<link href="/css/simplePagination.css" rel="stylesheet">
<link rel="stylesheet" href="/css/codemirror.css">
<link rel="stylesheet" href="/js/display/fullscreen.css">
<style>
.dark-theme .ellipse{
    background: #555;
    background: -moz-linear-gradient(top, #555 0%, #333 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#555), color-stop(100%,#333));
    background: -webkit-linear-gradient(top, #555 0%,#333 100%);
    background: -o-linear-gradient(top, #555 0%,#333 100%);
    background: -ms-linear-gradient(top, #555 0%,#333 100%);
    background: linear-gradient(top, #555 0%,#333 100%);
    }
    /*2016-06-18 @diego*/
    .codeMirrorTool{
        padding: 5px;
        background: #f6f6f6;
        border: 1px solid #bbb;
        border-bottom: none;
        overflow: hidden;
    }
    .codeMirrorTool .fullScreen,.codeLanguage{
        float: right;
    }
    .fullScreen{
        margin-left: 10px;
	}
	.rank .row{
	/*	border-bottom: 1px solid #ddd;*/
	}
	.rank .row:nth-child(odd) {
		background:#f5f5f5;
	}
	.rank .row div{
		padding-top:5px;
		padding-bottom:5px;
	}
	a.tag{
		font-size: 12px;
        border: 1px solid #ddd;
        padding: 1px 6px;
        border-radius: 5px;
        margin-left: 10px;
        color: green;
        background-color: rgba(1,126,102,.08);
	}
</style>
@stop
@section('title')
{{$task->title}}
@stop
@section('content')
<?php
use App\Utils;
use App\Permission;
$i=0;
?>



    <!-- Page Content -->
    <div class="contain">
		@if($task->id==138||$task->id==142)
		<input type="hidden" id="taskType" value="1"  />
		@else

		<input type="hidden" id="taskType" value="0"  />
		@endif
        <div class="row">

            <!-- Blog Post Content Column -->
            <div class="col-lg-8" style="display: inline-block; width:60%;vertical-align:top;">

                <!-- Blog Post -->

                <!-- Title -->
                <h1>{{$task['title']}}
@if($issolve)
        <a type="button" style="float:right" class="btn btn-success btn-lg" href="/q/{{Utils::id2url($dis[0]->id)}}#q-answer-form" target="_blank">撰写学习资料</a>
@endif


@if($task['id']==25||$task['id']==41||$task['id']==72||$task['id']==73||$task['id']==76||$task['id']==133||$task['id']==140||$task['id']==142||$task['id']==143)
<small><small> 最优化问题</small></small>
@elseif($task['id']==44)
<small><small> 1分/关，共1000关</small></small>
@elseif($task['id']==80)
<small><small> 第x关得x/2分，共63关</small></small>
@elseif($task['id']==95)
<br><small><small> 最优化问题，2046<a target="_blank" href="/help?tag=kuibu#kuibu">跬步</a>按最优化的方式分配给top的用户。<br>第一名1024跬步，第二名512跬步，第三名256跬步...以此类推直到第十名。<br>截止日期：2016年3月31号23时59分59秒。</small></small>
@else
    <small><small>{{$task->score/100}}积分</small>
        {{--<a class="tag" href=""></a>--}}
    </small>
@endif
        </h1>
                <!-- Author -->

                <!--Date/Time 
                <hr>
                <p><span class="glyphicon glyphicon-time"></span> Posted on August 24, 2013 at 9:00 PM</p>
                <hr>
-->
                <!-- Preview Image -->

                <hr>
                <!-- Post Content -->
                <p class="lead"><?php echo($task['content']);?></p>

                <hr name="comment" id="comment">

                <!--  user is not login S -->
@if(!Auth::check()&&$task['id']!=1)
                <div class="widget-comments__form">请先 <a class="commentLogin" href="javascript:void(0);">登录</a> 后提交答案</div>
@endif
                <!--  user is not login E -->

                <!-- Blog Comments -->
<?php
if((Auth::check()||$task['id']==1)&&(($issolve==false&&$task['id']!=69&&$task['id']!=95&&$task['id']!=80)||$task['id']==25||$task['id']==41||$task['id']==72||$task["id"]==73||$task["id"]==76||$task['id']==90||$task['id']==133||$task['id']==140||$task['id']==142||$task['id']==143))
{
if($task->id==35||$task->id==138||$task->id==142||$task->id==143||$task->id==139||$task->id==140||$task->id==142||$task->id==41)
echo '<div style="overflow:hidden;">';
else
echo '<div class="well clear">';
?>
                <!-- Comments Form -->
                    <h4>答案:</h4>
                    
                        <div class="form-group">
            {!! csrf_field() !!}
@if(Auth::check())
            <input type="hidden" name="phref" value="/task/<?php echo $task['id'];?>/solve">
@else
            <input type="hidden" name="phref" value="/firstsolve">
@endif

@if($task->id==35)
                <div id="test-editormd" style="width:100%;">                
                    <textarea name="answer" class="form-control" style="display:none;">###简短的使用教程

* 在左边书写markdown，右边预览html效果。
* 请将上面的菜单栏都试用一遍，对你的帮助会很大哦。
</textarea>
                </div>
@elseif($task->id==138)
	  <div class="codeMirrorTool">
        <button class="fullScreen">全屏</button>
        <select class="codeLanguage">
            <option data="text/x-python" value="python">python2.7</option>
            <option data="text/x-csrc" value="qll">qll</option>
          <!--  <option data="text/javascript" value="javascript">javascript</option>-->
           <!-- <option data="text/x-java" value="java">java</option>-->
        </select>
    </div>

<textarea id="editor" name="editor">
def encode(num):
    #todo
    return str


def decode(str):
    #todo
    return num
</textarea>
@elseif($task->id==139)
	  <div class="codeMirrorTool">
        <button class="fullScreen">全屏</button>
        <select class="codeLanguage">
            <option data="text/x-python" value="python">python2.7</option>
            <option data="text/x-csrc" value="qll">qll</option>
           <!-- <option data="text/javascript" value="javascript">javascript</option>-->
           <!-- <option data="text/x-java" value="java">java</option>-->
        </select>
    </div>

<textarea id="editor" name="editor">
print 'escape the sandbox'
</textarea>

@elseif($task->id==142||$task->id==143)
	  <div class="codeMirrorTool">
        <button class="fullScreen">全屏</button>
        <select class="codeLanguage">
            <option data="text/x-python" value="py">python2.7</option>
            <option data="text/x-c++src" value="cpp">cpp</option>
          <!--  <option data="text/javascript" value="javascript">javascript</option>-->
            <option data="text/x-java" value="java">java</option>
        </select>
    </div>

<textarea id="editor" name="editor">
import struct
def write_to_buffer(nums):
    buf = bytearray()
    for n in nums:
        bytes = struct.pack('i', n)
        buf.extend(bytes)
    return buf


def read_from_buffer(buf):
    nums = []
    ll = len(buf)
    for i in xrange(0, ll, 4):
        n, = struct.unpack('i', buf[i:i+4])
        nums.append(n)
    return nums
</textarea>
@elseif($task->id==140)
	  <div class="codeMirrorTool">
        <button class="fullScreen">全屏</button>
        <select class="codeLanguage">
            <option data="text/x-python" value="python">python2.7</option>
            <option data="text/x-csrc" value="qll">qll</option>
        </select>
    </div>

<textarea id="editor" name="editor">
mp = {}
# user_code
def get(key):
    return mp.get(key, 0)

def put(key):
    mp[key] = mp.get(key, 0)+1
    s = ''
    for kv in mp.items():
        s = '%s:%d\n' % kv + s
    b_s = bytearray(s)
    write_file(0, b_s)


def init():
    ls = map(chr, read_file(0, 102400))
    for li in ''.join(ls).split('\n'):
        l2 = li.split(':')
        if len(l2)<2:
            continue
        mp[l2[0]] = int(l2[1])
</textarea>


@elseif($task->id==41)
      <textarea name="answer" class="form-control" rows="15" style="width:612px;"></textarea>
@else
      <textarea class="form-control" rows="1" name="answer"></textarea>
@endif
						</div>
						<button type="submit" class="btn btn-primary solve pull-right">提交</button>
                   
                </div>
<?php
}
else if(Auth::check())
{
?>
                <div class="qa-a-reply" style="margin-bottom:20px;">
                    <form id="replyForm"  role="form" method="POST" action="/task/<?php echo $task['id'];?>/comment">
                        {!! csrf_field() !!}
                        <input class="ql_comment_editable editable" placeholder="说点什么吧^_^:" type="text" name="comment">
                        <div class="ql_command ql_clear none">
                            <button type="submit" class="btn btn-primary pull-right qa-replyBtn">回复</button>
                            <a href="javascript:;" class="qa-ql_comment_close qa-ql_command_cancel">取消</a>
                        </div>
                    </form>
                </div>
<?php
}
else if(!Auth::check()&&$task['id']==1)
{
?>

                <div class="qa-a-reply" style="margin-bottom:20px;">
                <div class="widget-comments__form">请先 <a class="commentLogin" href="javascript:void(0);">登录</a> 后评论题目</div>
                </div>
<?php
}
?>

<!-- code error -->	
<div id="codeError" style="display:none;border:1px solid #aaa;padding:10px;margin-top:20px;"></div>			

                <!--         Comments -->
<div id="dc" name="dc">
    <?php
    if($issolve || $task['id']==69||$task['id']==95)
    foreach($comments as $comment)
    {
    ?>
        <!-- Comment -->
        <div id="comment{{$comment->id}}" name="comment{{$comment->id}}"class="media">
            <a class="pull-left" target="_blank" href="/profile/{{Utils::id2url($comment->userid)}}">
                <img class="img-circle" alt="Cinque Terre" width="30" height="30" src="<?php echo $comment->url;?>" alt="">
            </a>
            <div class="media-body">
             <div  style="display:none">{{$comment->user->name}}</div>
                <h4 class="media-heading">
                    <a href="/profile/{{Utils::id2url($comment->userid)}}" class="username"  target="_blank">{{$comment->user->name}}</a>
                    <?php
                    if($comment->ruser!=null)
                    {
                        echo "<small> 回复 </small>";
                    ?>
                    <a href="/profile/{{Utils::id2url($comment->ruserid)}}" class="username"  target="_blank">{{$comment->ruser->name}}</a>
                    <?php
                    }
                    ?>
                </h4>
                {{$comment->comment}}
                <div class="ql_comment_ft">
                    <span class="date">{{substr($comment->updated_at,0,10)}}</span>
                    <?php
                        if(Auth::check()&&Auth::user()->id!==$comment->userid){
                            echo '<a href="javascript:;" class="reply ql_comment_op_link gray" name="reply_comment">回复</a>';
                        }
                    ?>
                    
                    <?php
                    if(Auth::check()&&( Permission::user_is_super(Auth::user()) ||Auth::user()->id==$comment->userid))echo '<a class="gray" target="_blank" href="/admin/del?id='.$comment->id.'">删除</a>';
                    ?>
                </div>

                <div class="ql_comment_form expanded" style="display: none;">
                    <div class="ql_comment_editable_wrap">
                        <div class="ql_comment_editable editable" aria-label="写下你的回复"  contenteditable="true"></div>
                    </div>
                    <div class="ql_command ql_clear">
                        <a href="javascript:;" class="btn btn-primary pull-right replyBtn" name="">回复</a>
                        <a href="javascript:;" class="ql_comment_close ql_command_cancel">取消</a>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }
    ?>
</div>
<br>


            </div>

            <!-- Blog Sidebar Widgets Column -->
            <div class="col-md-4" style="display: inline-block;width:39%;float:none;">
                <!-- Blog Search Well -->
                <div class="well">
        <h4>
        <img src="{{$author->avatar->url('thumb')}}" class="img-circle" alt="Cinque Terre" width="60" height="60">&nbsp&nbsp{{$author->name}}
        </h4>

        <h5>
        <i class="iconfont">&#xe608;</i>&nbsp&nbsp{{$author->company}} {{$author->title}}
        </h5>
                    <!-- /.input-group -->
        <h5>
        <i class="iconfont">&#xe60d;</i>&nbsp&nbsp{{$author->location}}
        </h5>
                    <!-- /.input-group -->
                </div>

      

                <!-- Side Widget Well -->
                <div class="well" >
                    <h4>{{$author->name}}说:</h4>
					<p><?php echo $task->material;?></p>
                </div>
<?php
if($task['id']==44||$task['id']==79||$task['id']==80)
{
?>
<div class="well">
                    <h4>奖励规则:</h4>
                    <p>首个通关的coder奖励顶配mac一台。(mac官网macbook系列任选)</p>
                    <a href="" data-toggle="modal" data-target="#myModal"><img src="http://www.qlcoder.com/uploads/145059173416304.png" style="width:100%;"></a>
                </div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width:1070px;margin:0 auto;transform: translateY(-50%); top: 50%; position: absolute; left: 50%; margin-left: -535px;">
        <div class="modal-content">

            <div class="modal-body" style="padding:0;">
                <img src="http://www.qlcoder.com/uploads/145059173416304.png" style="display: block;margin: 0 auto;width:95%;">
            </div>

        </div>
    </div>
</div>
<?php
}
else if($task['id']==68)
{
?>
<div class="well">
                    <h4>奖励规则:</h4>
                    <p>首个拿到1000分的coder奖励poker3一把。</p>
                    <a href="" data-toggle="modal" data-target="#myModal"><img src="http://www.qlcoder.com/uploads/144732661169783.jpg" style="width:100%;"></a>
                </div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width:1200px;margin:0 auto;">
        <div class="modal-content">

            <div class="modal-body" style="padding:0;">
                <img src="http://www.qlcoder.com/uploads/144732661169783.jpg" style="display: block;margin: 0 auto;">
            </div>

        </div>
    </div>
</div>
<?php
}
if($task['id']==25||$task['id']==41
    ||$task['id']==44||
    $task['id']==72
    ||$task['id']==73
    ||$task['id']==76
    ||$task['id']==80
    ||$task['id']==90
    ||$task['id']==95
    ||$task['id']==133
    ||$task['id']==140
    ||$task['id']==142
)
{
    echo '<div class="well" style="width:390px;background:white;">';
    echo '<h5>'.$task->title.'</h5>';
    if($task['id']==25)echo '<h4>装货排行榜</h4>';
    else if($task['id']==41) echo '<h4>uber车辆匹配排行榜</h4>';
    else if($task['id']==44) echo '<h4>扫地排行榜</h4>';
    else if($task['id']==80) echo '<h4>消消乐排行榜</h4>';
    else if($task['id']==90) echo '<h4>准确率排行榜</h4>';
    else if($task['id']==95) echo '<h4>遗传排行榜</h4>';
    else if($task['id']==133) echo '<h4>lambda fib排行榜</h4>';
    else if($task['id']==140) echo '<h4>持久化排行榜</h4>';
    else if($task['id']==72||$task['id']==73||$task['id']==76) echo '<h4>优秀代码排行榜</h4>';
    echo '<div style="height:602px;overflow:hidden;border:1px solid #ddd;" class="rank">';
foreach($rankusers as $rankuser)
{
if($rankuser->score==0)continue;
$i++;
?>
        <div class="row">

        <div class="col-md-1">
        {{$i}}
        </div>
        <div class="col-md-3 overhidden" >
        {{$rankuser->name}}
        </div>
        <div class="col-md-4 overhidden">
<?php
if($task['id']==25)echo $rankuser->score."kg";
else if($task['id']==41) echo ($rankuser->score/10)."百米";
else if($task['id']==44) echo ($rankuser->score)."关";
else if($task['id']==80) echo ($rankuser->score)."关";
else if($task['id']==72) echo ($rankuser->score)."字节";
else if($task['id']==73) echo ($rankuser->score)."字节";
else if($task['id']==76) echo ($rankuser->score)."字节";
else if($task['id']==90) echo sprintf("%.2f",($rankuser->score/300))."%";
else if($task['id']==95) echo ($rankuser->score/100)." points";
else if($task['id']==133) echo ($rankuser->score)." cnt";
else if($task['id']==140) echo ($rankuser->score)." byte";
else if($task['id']==142) echo ($rankuser->score)/10000;
?>
        </div>
        <div class="col-md-3" style="width:115px;">
<?php 
if($task['id']!=80&&$task['id']!=90&&$task['id']!=95&&$task['id']!=142)
echo ($rankuser->rscore/100)."分";
else if($task['id']==90){}
else if($task['id']==95){}
else if($task['id']==142){}
else echo ($rankuser->score*($rankuser->score+1)/4)."分";
?>
        </div>

        </div>
<?php
}
?>
</div>
<div id="fenye" style="margin-top:20px;"></div>

        </div>
<?php
}
?>
    
                <!-- Side Widget Well -->
        <a type="button" class="btn btn-primary btn-lg" href="/discuss/{{$task->title}}" target="_blank">查看讨论区</a>
        <br>
        <div>
        &nbsp
        </div>

         <?php if($task->id==18) echo '<video controls="" autoplay="" name="media" style="height: 0px;width: 100%;margin: 30px 0px;"><source src="http://www.qlcoder.com/uploads/music.mp3" type="audio/mpeg"></video>'; ?>
         <?php if($task->id==52) echo '<video controls="" autoplay="" name="media" style="height: 0px;width: 100%;margin: 30px 0px;"><source src="http://www.qlcoder.com/uploads/hot.mp3" type="audio/mpeg"></video>'; ?>
         <?php if($task->id==57) echo '<video controls="" autoplay="" name="media" style="height: 0px;width: 100%;margin: 30px 0px;"><source src="http://www.qlcoder.com/uploads/text.mp3" type="audio/mpeg"></video>'; ?>

            </div>

        </div>
        <!-- /.row -->

    </div>
    <div class="task-shadow none"></div>
    <img class="loadding_img none" src="/img/loadding.gif" alt="正在加载中" style="display: block;position: fixed;top: 50%;left: 50%;margin-top: -10px;margin-left: -50px;">
    <div class="authority none" style="width:550px;position:fixed;top:50%;left:50%;margin-top:-265px;margin-left:-275px;z-index: 2222222">
        <div class="authority-warp" style="position:relative">
            <a href="javascript:;" class="authority-close" style="position:absolute;top:6px;right:10px;">X</a>
            <div class="panel panel-login">
              <h2 style="margin-left: 30px;">千里码</h2>
  
            <p style="font-size: 18px;margin-left: 30px;">Code is cheap,show me the answer.</p>
                <!--<h2 style="margin-left: 30px;">千里码</h2>
  
            <p style="font-size: 18px;margin-left: 30px;">与开发者分享你的技术和实战经验</p>-->
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-6">
                            <a href="#" class="active" id="login-form-link">登录</a>
                        </div>
                        <div class="col-xs-6">
                            <a href="#" id="register-form-link" class="">注册</a>
                        </div>
                    </div>
                    <hr>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">
                            <form id="login-form" action="/auth/login" method="post" role="form" style="display: block;">
                                <input type="hidden" name="_token" value="{{csrf_token()}}">
                                <div class="form-group">
                                    <input type="text" name="email" id="email" tabindex="1" class="form-control" placeholder="邮箱" value="">
                                </div>
                                <div class="form-group">
                                    <input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="密码">
                                </div>
                                <div class="form-group text-center">
                                    <input type="checkbox" tabindex="3" class="" name="remember" id="remember">
                                    <label for="remember"> 记住我</label>
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-login" value="登录">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="text-center">
                                                <a href="/password/email" tabindex="5" class="forgot-password">忘记密码?</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                            <form id="register-form" action="/auth/register" method="post" role="form" style="display: none;">

                                <input type="hidden" name="_token" value="{{csrf_token()}}">
                                <div class="form-group">
                                    <input type="hidden" name="utm" id="utm" value="unknown">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="name" id="name" tabindex="1" class="form-control" placeholder="用户名" value="">
                                </div>
                                <div class="form-group">
                                    <input type="email" name="email" id="email" tabindex="1" class="form-control" placeholder="邮箱" value="">
                                </div>
                                <div class="form-group">
                                    <input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="密码">
                                </div>
                                <div class="form-group">
                                    <input type="password" name="password_confirmation" id="password_confirmation" tabindex="2" class="form-control" placeholder="再次输入密码">
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <input type="submit" tabindex="4" class="form-control btn btn-register" value="提交">
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="result-alert none">
        <div class="result_warp">
            <div class="warning">
                <i class="iconfont">&#xe616;</i><!-- true:&#xe617;   flase:&#xe616;  -->
            </div>
            <p>我是一条安安静静摸鱼的咸鱼~</p>
            <div class="query"><a class="btn btn-primary result-close">确定</a></div>
        </div>
        
    </div>
    <!-- /.container -->

    <!-- jQuery -->

    <!-- Bootstrap Core JavaScript -->
<!--
        <hr>

        <footer>
            <div class="row">
                <div class="col-lg-12">
                    <p>©2015 qlcoder.com | 联系我们:
                    oreo@qlcoder.com qq群480394714</p>
                </div>
            </div>
        </footer>
-->
@stop
@section("js")
<?php
if(Auth::check())
{
?>

<script type="text/javascript">
    <!-- 点击回复出现评论框-->
$(".modal-body img").click(function(){
        $("#myModal").modal('hide');
    })
    $(".reply").each(function(){
        $(this).click(function(){
            //$(".ql_comment_form").hide();
            $(this).parent().parent().parent().siblings().find(".ql_comment_form").hide();
            $(this).parent().siblings(".ql_comment_form").toggle();
        })
    })
//    取消评论
    $(".ql_command_cancel").click(function(){
        $(this).parent().parent(".ql_comment_form").toggle();
    })
//题目评论框聚焦
    $(".qa-a-reply input").focus(function(){
            $(this).next().removeClass("none");
        });
    $(".qa-a-reply .qa-ql_command_cancel").click(function(){
            $(this).parent().addClass("none");
        });
	$("button.qa-replyBtn").click(function(e){
		e.preventDefault();
		if($("input.ql_comment_editable").val()==""){
			return !1;
		}else{
			$("#replyForm").submit();
		}
	})
//回复之后跳到 我回复的内容
var dc=$("#dc");
    $(".replyBtn").click(function(){
    //$(".ql_comment_form").hidden();
        $(this).parent().parent(".ql_comment_form").toggle();
    var content=$(this).parent().prev().text();
		if(content==''){
			return !1;
		}
var replyname=$(this).parent().parent().prev().prev().prev().text();
dc.prepend( '<div class="media">'+
        '<a class="pull-left" href="{{Auth::user()->id}}">'+
        '<img class="img-circle" alt="Cinque Terre" width="40" height="40" src="{{Auth::user()->avatar->url('thumb')}}" alt="">'+
        '</a>'+
        '<div class="media-body">'+
        '<h4 class="media-heading">{{Auth::user()->name}}                <small>回复 </small> '+replyname+'</h4>'
            +   content+    '<div class="ql_comment_ft">'+
                        '<span class="date">最近发布</span>'+
                    '</div>'+
        '</div>'+
'</div>'
);
$('html,body').animate({scrollTop:$("#comment").offset().top}, 800);
var posting = $.post( "/task/{{$task['id']}}/comment", { reply:replyname,comment: content,_token:'{{csrf_token()}}'});

posting.done(function( data ) {
         // var div=document.getElementById("abc");
});
})
</script>
<?php
}
?>
<script src="/js/editormd.js?v=1.0"></script>
<script src="/js/login.js"></script>
<script src="/js/codemirror.js"></script>
<script src="/js/mode/python/python.js"></script>
<script src="/js/mode/clike/clike.js"></script>
<script src="/js/display/fullscreen.js"></script>
<script type="text/javascript">
    var testEditor;
    //is pass?
    var _flag=false;
    $(function() {
		@if($task['id']==35)
        editormd.methodOne = function() {
        };

        testEditor = editormd("test-editormd", {
            width  : "100%",
            height : 720,
            path   : '/lib/',
            onload : function() {
            }
        });

        editormd.methodOne();
		@endif
        @if($task['id']==138||$task['id']==142||$task['id']==143||$task['id']==139||$task['id']==140)
            codeMirrorEditor();
			var javascript="console.log('hello world')";
      	    var python=$("#editor").html();
       	    var codeLanuage={javascript:javascript,python:python};
            $("select").change(function(){
                var type=$(this).find("option:selected").val();
                var child=$(this).find("option:selected").attr('data');
				
				$("#editor").html(codeLanuage[type]);
                $(".CodeMirror").remove();
                codeMirrorEditor(child);
            })
        @endif
        $("#fenye").pagination({
            prevText:"上一页",
            nextText:"下一页",
            ulClass:"in clearfix",
            items: {{$i}},//--总个数
            itemsOnPage: 20,//--个数
            currentPage:1,//-当前
            //hrefTextSuffix:"javascript:;",
            hrefText:"",
            onPageClick:function(pageNumber, event){
                console.log(pageNumber);
                $(".well .row").removeAttr("style");
                $(".well .row").slice(0,(pageNumber-1)*20).css({"height":"0","overflow":"hidden"});
                }
            });
        $("button.solve").click(function(){
            var val=$("textarea.form-control").val() || localStorage.getItem("codeMirror");
            var token=$("input[name='_token']").val();
            var _href=$("input[name='phref']").val();
            var lan= "" || $(".codeLanguage").val() ;
            $(".task-shadow").toggleClass("none");
            $(".loadding_img").removeClass("none");
            $.ajax({
                url:_href,
                timeout:60000,
                type:"<?php if($task['id']==4)echo 'get';else echo 'post';?>",
                data:{answer:val,_token:token,lan:lan},
                dataType:"json",
                success:function(data){
                    if(data.success==true)
                    {
                        $(".result_warp").removeClass("none");
                        $(".result-alert").toggleClass("none").find(".warning").find("i").html("&#xe617;").css("color","#2aa515");
                        $(".result-alert p").html(data.result);
                        _flag=true;
                    }
                    else{
                       /* $(".result_warp").removeClass("none");
                        $(".result-alert").toggleClass("none").find(".warning").find("i").html("&#xe616;");
					   $(".result-alert p").html(data.result);*/
						if($("#taskType").val()==1){//区分代码题还是普通题，代码题错误的话不弹框
							$("#codeError").show().html(data.result);
							$(".task-shadow,.result-alert,.loadding_img").addClass('none');
							window.location.hash="codeError";
						}else{
							$(".result_warp").removeClass("none");
							$(".result-alert").toggleClass("none").find(".warning").find("i").html("&#xe616;");
							$(".result-alert p").html(data.result);
						}
                    }
                },
                complete:function(XMLHttpRequest,status){
                        if(status=='timeout'){
                            $(".result_warp").removeClass("none");
                            $(".result-alert").toggleClass("none").find(".warning").find("i").html("&#xe616;");
                            $(".result-alert p").html("请求超时，请重新尝试！");
                        }
                }
            })
            
        });
        $(".commentLogin").click(function(){
            $(".authority,.task-shadow").removeClass("none");
        })
        $(".result-close").click(function(){
            if(_flag){
                window.location.reload();
            }
            else{
                $(".task-shadow").addClass("none");
                $(".result-alert").addClass("none");
                $(".loadding_img").addClass("none");
            }
        })
        $(".authority-close").click(function(){
            $(".authority,.task-shadow").addClass("none");
        });
});
function codeMirrorEditor(mode){
        var myTextarea = document.getElementById('editor');
        var CodeMirrorEditor = CodeMirror.fromTextArea(myTextarea, {
            mode: mode || "text/x-python",
            lineNumbers: true,
//            value: localStorage.getItem("codeMirror") || "",
            extraKeys: {
                "F11": function(cm) {
                    cm.setOption("fullScreen", !cm.getOption("fullScreen"));
                },
                "Esc": function(cm) {
                    if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
                }
            }
        });
        $(".fullScreen").click(function(){
            CodeMirrorEditor.setOption("fullScreen", !CodeMirrorEditor.getOption("fullScreen"));
            if(CodeMirrorEditor.getOption("fullScreen")) {
                $(this).css({"position":"fixed","top":"5px","right":"5px","z-index":"11"}).html("取消全屏");
            }else{
                $(this).removeAttr("style").html("全屏");
            }
        });
		localStorage.setItem("codeMirror",$("#editor").val());
        //load code
		/*if(localStorage.getItem('codeMirror')){
			CodeMirrorEditor.setOption("value",localStorage.getItem("codeMirror") || "");
}*/
        //save code
        CodeMirrorEditor.on("change",function(){
            localStorage.setItem("codeMirror", CodeMirrorEditor.getValue());
            console.log(localStorage.getItem("codeMirror"));
})
    }
</script>
<script src="/js/jquery.simplePagination.js"></script>
@stop
